What is @bugsnag/core?
@bugsnag/core is a core library for the Bugsnag error monitoring service. It provides the essential functionality for capturing and reporting errors in your applications. This package is typically used as a dependency for other Bugsnag notifier packages that are specific to different platforms (e.g., JavaScript, React Native, etc.).
What are @bugsnag/core's main functionalities?
Initializing Bugsnag
This code initializes the Bugsnag client with your API key, allowing you to start capturing and reporting errors.
const Bugsnag = require('@bugsnag/core');
const bugsnagClient = Bugsnag.createClient({ apiKey: 'YOUR_API_KEY' });
Notifying Errors
This code sends a notification to Bugsnag about an error. This is useful for capturing and reporting errors that occur in your application.
bugsnagClient.notify(new Error('Test error'));
Adding Metadata
This code adds custom metadata to the error report, which can be useful for providing additional context about the error.
bugsnagClient.notify(new Error('Test error'), event => {
event.addMetadata('account', {
id: 123,
name: 'Acme Co'
});
});
Breadcrumbs
This code leaves a breadcrumb, which is a log of actions that happened before an error occurred. Breadcrumbs help in understanding the sequence of events leading up to an error.
bugsnagClient.leaveBreadcrumb('User clicked button', { buttonName: 'Submit' });
Other packages similar to @bugsnag/core
sentry
Sentry is another popular error tracking and monitoring service. It provides similar functionalities to Bugsnag, such as capturing and reporting errors, adding metadata, and breadcrumbs. Sentry also offers additional features like performance monitoring and release tracking.
rollbar
Rollbar is an error monitoring service that provides real-time error tracking and debugging tools. It offers similar functionalities to Bugsnag, including error notification, metadata addition, and breadcrumbs. Rollbar also provides features like deployment tracking and error grouping.
airbrake
Airbrake is an error monitoring service that helps you track and fix errors in your applications. It offers similar functionalities to Bugsnag, such as error notification, metadata addition, and breadcrumbs. Airbrake also provides features like performance monitoring and error grouping.
@bugsnag/core
This package contains the core classes and utilities common to the Bugsnag notifier for any JS-based platform:
Client
classEvent
classBreadcrumb
classSession
classconfig
scheme and utils- Basic JS polyfills that don't pollute the global scope (for support back to IE8)
- and a couple of other small utilities
Unless you are writing your own notifier, it is unlikely that you want to install this module – for the universal error reporting client, see @bugsnag/js.
License
This package is free software released under the MIT License. See LICENSE.txt for details.